package com.liang.subject.domain.job;

import com.liang.subject.domain.service.SubjectLikedDomainService;
import com.liang.subject.infra.basic.service.SubjectLikedService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 同步点赞数据
 */
@Slf4j
@Component
public class SyncLikedXxlJob {
    @Resource
    private SubjectLikedDomainService subjectLikedDomainService;

    /**
     * 同步点赞数据任务
     */
    @XxlJob("syncLikedJobHandler")
    public void syncLikedJobHandler() throws Exception {
        try {
            subjectLikedDomainService.syncLiked();
            log.info("syncLikedJobHandler.start");
        } catch (Exception e) {
            log.error("syncLikedJobHandler.error{}", e.getMessage());
            throw new RuntimeException(e);
        }
    }
}
